<template>
  <div class="diary-cover">
    <nuxt-link :to="`/diary/${datas.diary_group_id}`">
      <div
        class="diary-image"
        :style="{background: `url('${ datas.after_image.thumbnail_url }') center center no-repeat`,backgroundSize:'cover'}"
      >
        <div class="diary-frame">
          <div class="diary-frame-text">
            {{ datas.project[0].project_name }}
          </div>
          <div class="diary-frame-icon" />
          <div class="diary-frame-text-right">
            日记
          </div>
        </div>
      </div>
    </nuxt-link>

    <div class="diary-content">
      <nuxt-link :to="`/diary/${datas.diary_group_id}`">
        <div class="diary-content-title">
          {{ datas.diary_content }}
        </div>
      </nuxt-link>

      <div class="diary-user-wrap">
        <div class="diary-user">
          <div
            class="diary-user-photo"
            :style="{background:'url('+datas.user.user_photo+') center center no-repeat',backgroundSize:'100% 100%'}"
          />
          <div class="diary-user-name">
            {{ datas.user.user_name }}
          </div>
        </div>
        <div class="diary-browse-count">
          浏览 {{ datas.browse_count }}
        </div>
      </div>
      <div class="diary-hospital-wrap">
        <div class="diary-hospital">
          <a :href="setUrl(datas.diary_group_id)" class="diary-hospital-name">
            {{ datas.hospital.user_name }}
          </a>
          <div class="diary-hospital-price">
            <div class="consultation-text">
              指导价：
            </div>
            <p class="pice">
              {{ min_price }}~{{ max_price }}
            </p>
          </div>
        </div>
        <nuxt-link to="/aboutus" rel="nofollow">
          <div class="diary-hospital-consultation">
            咨询
          </div>
        </nuxt-link>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  components: {

  },
  props: {
    datas: {
      type: Object,
      default: () => { }
    }
  },
  data() {
    return {
      max_price: '',
      min_price: ''
    }
  },
  computed: {

  },
  created() {
    this.max_price = this.million(parseFloat(this.datas.max_price))
    this.min_price = this.million(parseFloat(this.datas.min_price))
  },
  mounted() {

  },
  methods: {
    million(value) { // 过万处理
      let num
      if (value > 9999) { // 大于9999显示x.xx万
        num = (Math.floor(value / 1000) / 10) + '万'
      } else if (value < 9999 && value > -9999) {
        num = value
      } else if (value < -9999) { // 小于-9999显示-x.xx万
        num = -(Math.floor(Math.abs(value) / 1000) / 10) + '万'
      }
      return num
    },
    setUrl(i) {
      // console.log(i)
      return `https://rongcat.com${this.$route.path}${i}`
    }

  }
}
</script>
<style scoped lang="scss">
.diary-cover {
  width: 290px;
  height: 450px;
  background: #fff;
  border-radius: 4px;
  margin-top: 10px;
  border-bottom: 1px solid rgba(246, 246, 246, 1);
  .diary-image {
    width: 290px;
    height: 290px;
    position: relative;
  }
  .diary-image:hover{
    cursor: pointer;
  }
  .diary-frame {
    width: 125px;
    height: 26px;
    background: url("~assets/img/diary-frame.png") center center no-repeat;
    background-size: 100% 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    left: 0;
    bottom: 0;
  }
  .diary-frame-icon {
    width: 1px;
    height: 15px;
    margin: 0 5px;
    background: #fff;
  }
  .diary-frame-text-right {
    font-size: 14px;
    color: rgba(255, 255, 255, 1);
    line-height: 20px;
  }
  .diary-frame-text {
    width: 70px;
    font-size: 14px;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);
    line-height: 20px;
    text-align: center;
       overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 1;
      -webkit-box-orient: vertical;
  }
  .diary-content {
    margin-top: 10px;
    padding: 0 10px;
    .diary-content-title {
      width:271px;
      height:44px;
      font-size:16px;
      font-family:PingFangSC-Semibold,PingFang SC;
      font-weight:600;
      color:rgba(51,51,51,1);
      line-height:22px;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }
    .diary-content-title:hover{
      cursor: pointer;
    }
  }
}
.diary-user-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  .diary-user {
    display: flex;
    align-items: center;
    .diary-user-photo {
      width: 26px;
      height: 26px;
      border-radius: 50%;
    }
    .diary-user-name {
      font-size: 14px;
      font-weight: 400;
      color: rgba(153, 153, 153, 1);
      line-height: 20px;
      margin-left: 8px;
    }
  }
  .diary-browse-count {
    font-size: 14px;
    font-weight: 400;
    color: rgba(153, 153, 153, 1);
    line-height: 20px;
  }
}
.diary-hospital-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  .diary-hospital-name {
    font-size: 12px;
    font-weight: 400;
    color: rgba(153, 153, 153, 1);
    line-height: 17px;
  }
  .diary-hospital-consultation {
    width: 58px;
    height: 32px;
    border-radius: 4px;
    border: 2px solid rgba(239, 239, 239, 1);
    font-size: 14px;
    font-weight: 500;
    color: rgba(102, 102, 102, 1);
    line-height: 25px;
    text-align: center;
  }
  .diary-hospital-consultation:hover{
    cursor: pointer;
  }
}
.diary-hospital-price {
  display: flex;
  align-items: center;
  .consultation-text {
    font-size: 12px;
    font-weight: 400;
    color: rgba(153, 153, 153, 1);
    line-height: 17px;
  }
  .pice {
    font-size: 12px;
    font-weight: 400;
    color: #ff4567;
    line-height: 17px;
    margin-top: 3PX;
  }
}
</style>
